package de.stefanocke.roo.kontaktliste.web.common;

import java.io.Serializable;
import java.util.List;

import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
import org.apache.wicket.model.IModel;
import org.springframework.web.bind.annotation.InitBinder;

import de.stefanocke.roo.wicket.RooStereotype;

/**
 * Entity-related Bindings. An Entity is uniquely identifiable, can be queried (-> DataProvider) and one can perform
 * CRUD actions for it. 
 * 
 * @author stefan
 *
 * @param <T>
 * @param <ID>
 */
@RooStereotype("wicket.IEntityBindings")
public interface IEntityBindings<T, ID extends Serializable> extends IBindings<T>{


	/** IDs for default actions */
	String ACTION_ID_CREATE = "create";
	String ACTION_ID_UPDATE = "update";
	String ACTION_ID_DELETE = "delete";
	String ACTION_ID_SAVE = "save";
	
	/**
	 * Creates a dataprovider that allows to iterate through the entities in the given context.
	 * <p>
	 * TODO: Do we something like fetch params here, to allow the Table to only retrive the data it needs?
	 * 
	 * @return the DataProvider
	 */
	ISortableDataProvider<T, String> createDataProvider();

	/**
	 * Creates a model for a given entity instance
	 * @param object
	 * @return the model
	 */
	IModel<T> createModel(T object);

	/**
	 * Creates a model for a given ID.
	 * @param the ID
	 * @return the model
	 */
	IModel<T> createModelById(ID id);

	/**
	 * 
	 * @return the actions that can be executed for a single existing entity
	 */
	List<IAction<?, IModel<T>>> getSingleEntityActions();


	List<IAction<IModel<T>, Class<T>>> getCreateActions();

	List<IAction<IModel<T>, IModel<T>>> getSaveActions();
	
//	/** An action takes a class a parameter and returns a model.*/
//	interface IClassParamModelReturnAction<T> extends IAction<IModel<T>, Class<T>>{};
//	
//	/** An action that takes a single model param */
//	interface ISingleModelParamAction<R, T> extends IAction<R, IModel<T>>{};
//	
//	/** A SingleEntity Action takes one model a returns a model */
//	interface ISingleModelParamAndReturnAction<T> extends ISingleModelParamAction<IModel<T>, T>{};
//	
//	/** A SingleEntity Action takes one model a returns nothing */
//	interface ISingleModelParamNoReturnAction<T> extends ISingleModelParamAction<Void, T>{};
	
	

}